trigger OppLineItem on OpportunityLineItem (before insert, before update, after insert, after update) {
    if(!Validation.getOppTriggerFired()){
        if(Trigger.isAfter){
            List<CampaignMember> cmToInsert=new List<CampaignMember>();
            for(OpportunityLineItem oli : Trigger.new){
                System.debug('xxx before if loop');
                if(oli.Campaign_Member_ID__c==null&&oli.Contact__c!=null&&oli.Campaign__c!=null){
                    System.debug('xxx in if loop');
                    cmToInsert.add(new CampaignMember(ContactId=oli.Contact__c, CampaignId=oli.Campaign__c, Income_Item__c=oli.OpportunityId));
                }
            }
            if(!cmToInsert.isEmpty()){
                try{
                    System.debug('xxx about to insert');
                    insert cmToInsert;
                }
                catch(Exception e){
                }
            }
        }
    }
}